#include <gtkhpp>

using namespace gtkhpp;

//gboolean button_press_callback(GtkWidget *widget, GdkEventButton *event, GdkWindowEdge edge);
gboolean button_press_callback(GtkWidget *widget, GdkEventButton *event);
void button_clicked_callback(void *button, gpointer user_data);

static inline void app_quit(Application *app) { app->quit(); }

int main(int argc,char *argv[])
{
	Application app(&argc, &argv);
	Button button("Hello");

	Window w(Window::TOPLEVEL);
	w.set_title("Hello world");

#if 1
	//    w.set_decorated(false);
	w.set_default_size(230, 150);
	w.add_events(Widget::BUTTON_PRESS_MASK);
	//g_signal_connect(G_OBJECT(window), "button-press-event", G_CALLBACK(button_press_callback), NULL);
#else
	w.fullscreen();
#endif
	w.set_backgroup(Widget::STATE_NORMAL, Widget::BLACK);

	
	w.connect("destroy", Callback(app_quit), &app);
	w.connect("button-press-event", Callback(button_press_callback), NULL);
	button.connect("clicked", Callback(button_clicked_callback), (void *)1);

	/* and insert it into the main window */
	w.add(button);

	w.show();

	/* start application */
	app.run();

	return 0;
} 


//gboolean button_press_callback(GtkWidget *widget, GdkEventButton *event, GdkWindowEdge edge)
gboolean button_press_callback(GtkWidget *widget, GdkEventButton *event)
{
    if (event->type == GDK_BUTTON_PRESS) {
        if (event->button == 1) {
            gtk_window_begin_move_drag(
                        GTK_WINDOW(gtk_widget_get_toplevel(widget)),
                        event->button,
                        event->x_root,
                        event->y_root,
                        event->time);
        }
    }
    return FALSE;
}

void button_clicked_callback(void *button,  gpointer user_data)
{
	g_message("user_data = %p\n", user_data);
}
